﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;

using Gift.DAL;
using Gift.Model;


namespace WebSite.admin
{
    public partial class head : System.Web.UI.UserControl
    {
        // Fields
        protected ImageButton ImageButton1;
        readonly dalCompany theCompany = new dalCompany();
        readonly adminlogin theAdminLogin = new adminlogin();
        string _loginUserMessage = string.Empty;

        public string LoginUserMessage
        {
            get { return _loginUserMessage; }
            set { _loginUserMessage = value; }
        }

        // Methods
        protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
        {
            base.Session["Adminlogin"] = null;
            base.Session["Uid"] = null;
            base.Response.Write("<script language=javascript>window.top.location.href='login.aspx';</script>");
            base.Response.End();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.Session["Adminlogin"] == null)
            {
                base.Response.Write("<script language=javascript>window.top.location.href='login.aspx';</script>");
                base.Response.End();
            }
            else
            {

                int iAdminId = theAdminLogin.GetIdByName(this.Session["Adminlogin"].ToString());

                tbCompany oCompany = theCompany.GetModelByAdminId(iAdminId);
                if (oCompany != null && base.Session["AdminTypeId"].ToString() != "1")
                {
                   
                    _loginUserMessage = oCompany.Name;
                }
                else
                {
                    _loginUserMessage = base.Session["Adminlogin"].ToString();
                }
            }
   
        }

    }
}